import React, { useEffect, useState } from 'react'
import UserWaterfall from '../../../widgets/Waterfall/UserWaterfall'
import { SearchService } from '../../../transfer/service/SearchService'
import BlankView from '../../../widgets/BlankView'

export default function SearchUser(props: any) {
    const [show, setShow] = useState<boolean>()

    useEffect(() => {
        new SearchService().get('users', encodeURI(props.params.searchValue), 0, 20).then(res => {
            res.data.data.length != 0 ? setShow(true) : setShow(false)
        })
    }, [])

    return <>{show ? <UserWaterfall searchValue={props.params.searchValue} /> : <BlankView />}</>
}
